<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>老虎机在线抽机</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="./js/jquery.slotmachine.js"></script>
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div class="line">
    <div class="content" style="text-align: center">
        <div style="clear:both;">
            <div id="machine1" class="slotMachine">
                <div class="slot slot1"></div>
                <div class="slot slot2"></div>
                <div class="slot slot3"></div>
                <div class="slot slot4"></div>
                <div class="slot slot5"></div>
                <div class="slot slot6"></div>
            </div>
            <div id="machine2" class="slotMachine">
                <div class="slot slot1"></div>
                <div class="slot slot2"></div>
                <div class="slot slot3"></div>
                <div class="slot slot4"></div>
                <div class="slot slot5"></div>
                <div class="slot slot6"></div>
            </div>
            <div id="machine3" class="slotMachine">
                <div class="slot slot1"></div>
                <div class="slot slot2"></div>
                <div class="slot slot3"></div>
                <div class="slot slot4"></div>
                <div class="slot slot5"></div>
                <div class="slot slot6"></div>
            </div>
        </div>
        <div class="index" style="clear:both;">
            <div id="machine1Result" class="slotMachine noBorder" style="text-align:left">Index: 0</div>
            <div id="machine2Result" class="slotMachine noBorder" style="text-align:left">Index: 1</div>
            <div id="machine3Result" class="slotMachine noBorder" style="text-align:left">Index: 2</div>
            <div class="slotMachine noBorder"></div>
        </div>
        <div>
            <button id="slotMachineButton1" class="slotMachineButton">start</button>
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        var machine1 = $("#machine1").slotMachine({
            active	: 0,
            delay	: 1000
        });

        var machine2 = $("#machine2").slotMachine({
            active	: 1,
            delay	: 1000
        });

        var machine3 = $("#machine3").slotMachine({
            active	: 2,
            delay	: 1000
        });

        function onComplete($el, active){
            switch($el[0].id){
                case 'machine1':
                    $("#machine1Result").text("Index: "+active.index);
                    break;
                case 'machine2':
                    $("#machine2Result").text("Index: "+active.index);
                    break;
                case 'machine3':
                    $("#machine3Result").text("Index: "+active.index);
                    break;
            }
        }

        $("#slotMachineButton1").click(function(){

            machine1.shuffle(3, onComplete);

            setTimeout(function(){
                machine2.shuffle(3, onComplete);
            }, 500);

            setTimeout(function(){
                machine3.shuffle(3, onComplete);
            }, 1000);

        })
    });
</script>
</body>
</html>